package cn.aku.Plus;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class TestEmp {
    public static void main(String[] args) {
        List<Emp> list = new ArrayList<>();
        Emp e1 = new Emp("张三",90);
        Emp e2 = new Emp("李四",100);
        Emp e3 = new Emp("王五",70);
        list.add(e1);
        list.add(e2);
        list.add(e3);
        System.out.println(list);
//		list.sort();  需要定义一个临时比较器
        //Comparator
//		list.sort(new MyCompare());
        Collections.sort(list);
        System.out.println(list);
    }
}
class MyCompare implements Comparator<Emp>{

    @Override
    public int compare(Emp o1, Emp o2) {
        return o1.score>o2.score?1:-1;
    }

}
